package flc.ast.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.cartoonavatarmaker.lib.core.AvatarTemplate;
import com.stark.cartoonavatarmaker.lib.core.AvatarTemplateCategory;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class TemplateAdapter extends StkProviderMultiAdapter<AvatarTemplate> {

    public TemplateAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new TemplateProvider());
    }

    private class TemplateProvider extends BaseItemProvider<AvatarTemplate> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_template;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, AvatarTemplate bean) {
            Glide.with(getContext()).load(bean.getImgUri())
                    .into((ImageView) baseViewHolder.getView(R.id.ivTemplateItemImg));
            baseViewHolder.setText(R.id.tvTemplateItemName, bean.name);
        }
    }

}
